package com.hong.demo.other.flink;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;

public class FilterTest {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<Integer> stream = env.fromCollection(Arrays.asList(1, 2, 3));

        SingleOutputStreamOperator<Integer> source = stream.filter(new FilterFunction<Integer>() {

            @Override
            public boolean filter(Integer a) throws Exception {
                return a != 2;
            }
        });

        source.print();

        env.execute();
    }
}
